package org.tinygroup.restpractice.service;

import java.util.List;

import org.tinygroup.restpractice.dao.UserDao;
import org.tinygroup.restpractice.pojo.User;
import org.tinygroup.service.annotation.ServiceComponent;
import org.tinygroup.service.annotation.ServiceMethod;
import org.tinygroup.service.annotation.ServiceResult;

@ServiceComponent(bean="userService")
public class TinyUserService implements UserService {
	
	private UserDao userDao;
	
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	@ServiceMethod(serviceId = "addUser")
	@ServiceResult(name = "user")
	public User addUser(User user) {
		return userDao.addUser(user);
	}

	@ServiceMethod(serviceId = "updateUser")
	@ServiceResult(name = "record")
	public int updateUser(User user) {
		return userDao.updateUser(user);
	}

	@ServiceMethod(serviceId = "deleteUser")
	@ServiceResult(name = "record")
	public int deleteUser(User user) {
		return userDao.deleteUser(user);
	}

	@ServiceMethod(serviceId = "queryUsers")
	@ServiceResult(name = "users")
	public List<User> queryUsers(User user) {
		return userDao.queryUsers(user);
	}

	@ServiceMethod(serviceId = "queryUserById")
	@ServiceResult(name = "user")
	public User queryUserById(String id) {
		return userDao.queryUserById(id);
	}

}
